success = 0
err_db = 1
err_unknown = 2

err_no_such_user = 101
err_password_error = 102
err_validate_failed = 103

err_password_confirm_error = 111

err_extra_info = {
  success: 'Success.',
  err_db: 'Unknown db error.',
  err_unknown: 'Unknown error.',

  err_no_such_user: 'No such user.',
  err_password_error:'Password error.',
  err_validate_failed:'Validate failed.',

  err_password_confirm_error:'password confirm error.',
}

def get_extra_info(res_code):    
    if err_extra_info.has_key(res_code):
        return err_extra_info[res_code]
    else:
        return "Unknown error: %d" % res_code
        

if __name__ == '__main__':
    print success, get_extra_info(success)
    print err_no_such_user, get_extra_info(err_no_such_user)
    print err_validate_failed, get_extra_info(err_validate_failed)
    print get_extra_info(-1)